package com.foucus.myfouces.Adapter;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.util.Log;

import com.foucus.myfouces.MVP.View.views.Fragment.SelectRecommentFragment;

/**
 * Created by yf-06 on 2017/7/13.
 */

public class ViewpagerAdapter extends FragmentPagerAdapter {
    private String[] titles = new String[]{"今日精选", "电影预告", "热血连载"};
    private String type[] = {"今日精选", "电影预告", "热血连载"};
    private Context context;
    Bundle bundle;

    public ViewpagerAdapter(FragmentManager fm, Context context) {
        super(fm);
        this.context = context;
    }

    @Override
    public Fragment getItem(int position) {
        Fragment mainFragment = null;
        bundle = new Bundle();
        bundle.putString("type", type[position]);
        Log.e("ssss", "发送positon==》" + position);
        Log.e("ssss", "发送==》" + type[position]);
        switch (position) {
            case 0:
                mainFragment = new SelectRecommentFragment();
                mainFragment.setArguments(bundle);
                break;
            case 1:
                mainFragment = new SelectRecommentFragment();
                mainFragment.setArguments(bundle);
                break;
            case 2:
                mainFragment = new SelectRecommentFragment();
                mainFragment.setArguments(bundle);
                break;
        }
        return mainFragment;
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
